﻿namespace Common
{
    using Microsoft.DirectX.DirectSound;
    using System;
    using System.Windows.Forms;

    public class MyDirectSound
    {
        public static Device device;

        public static void Free()
        {
            if (device != null)
            {
                device.Dispose();
                device = null;
            }
        }

        public static bool Initialize(Control control)
        {
            try
            {
                device = new Device();
                device.SetCooperativeLevel(control, CooperativeLevel.Priority);
            }
            catch
            {
                return false;
            }
            return true;
        }
    }
}

